using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameObjectPool : PoolBase
{
    public override UnityEngine.Object Spwan(string name)
    {
        UnityEngine.Object obj = base.Spwan(name);
        if(obj == null)
            return null;

        GameObject go = obj as GameObject;
        go.SetActive(true);
        return obj;
    }

    public override void UnSpwan(string name, UnityEngine.Object obj)
    {
        GameObject go = obj as GameObject;
        go.SetActive(false);
        go.transform.SetParent(this.transform, false);
        base.UnSpwan(name, obj);
    }

    public override void Release()
    {
        base.Release();
        foreach(PoolObject poolObject in this.m_objects) 
        {
            if(DateTime.Now.Ticks - poolObject.LastUseTime.Ticks >= m_ReleaseTime * 10000000)
            {
                Debug.Log("GameObjectPool Release Time" + DateTime.Now);
                Destroy(poolObject.Object);
                Manager.Resource.MinusBundleCount(poolObject.Name);
                m_objects.Remove(poolObject);
                Release();
                return;
            }
        }
    }
}
